package com.sikao.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sikao.app.R;
import com.sikao.app.bean.NoticeBean;
import com.sikao.app.utils.TimeUtil;

import java.util.List;

/**
 * Created by y50 on 2016/5/16.
 */
public class NoticeAdapter extends BaseAdapter {

	private Context context;
	private List<NoticeBean.ResBean.ListBean> beans;

	public NoticeAdapter(Context context, List<NoticeBean.ResBean.ListBean> beans) {
		this.context = context;
		this.beans = beans;
	}
	@Override
	public int getCount() {
		return beans.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view;
		ViewHolder holder;
		if (convertView == null){
			view = View.inflate(context, R.layout.notice_list_item,null);
			holder = new ViewHolder(view);
			view.setTag(holder);
		}else{
			view = convertView;
			holder = (ViewHolder) view.getTag();
		}
		holder.tvtitle.setText(beans.get(position).getTitle() +"|"+ beans.get(position).getTitle());
		holder.tvtime.setText(TimeUtil.timeStampToTime(beans.get(position).getCreate_time(),TimeUtil.fotmatString2));
		//holder.tvname.setText(beans.get(position).getAuther());
		holder.tvbrowsevolume.setText(beans.get(position).getView());
		holder.contenttv.setText(beans.get(position).getDescription());
		return view;
	}

	public class ViewHolder {
		public final TextView tvtitle;
		public final TextView tvtime;
		public final TextView contenttv;
		public final TextView tvname;
		public final TextView tvbrowsevolume;
		public final View root;

		public ViewHolder(View root) {
			tvtitle = (TextView) root.findViewById(R.id.tv_title);
			tvtime = (TextView) root.findViewById(R.id.tv_time);
			contenttv = (TextView) root.findViewById(R.id.content_tv);
			tvname = (TextView) root.findViewById(R.id.tv_name);
			tvbrowsevolume = (TextView) root.findViewById(R.id.tv_browse_volume);
			this.root = root;
		}
	}
}
